from conn import *
import time

class connManager():
	def __init__(self):
		self.connList = []

	def addConn(self, conn):
		self.connList.append(conn)

	def delConn(self, conn):
		if conn in self.connList:
			self.connList.remove(conn)

	def D_print(self):
		for c in self.connList:
			print c.fd

	def loop(self):
		while(1):
			for c in self.connList:
				if c.isActive == 0:
					continue
				try:
					data = c.recv();
					print data
					if data :
						if c.callback:
							c.callback(data, c)
					else :
						print c.fd
				except:
					pass
			time.sleep(2)
			self.D_print()
			#callback = c.getCallBack()
			#callback(xxx);

global_cm = connManager();


